package com.tencent.qf.team.controller;

import com.alibaba.fastjson.JSON;
import com.tencent.qf.common.pojo.HttpResult;
import com.tencent.qf.team.dto.request.SharerOutOrderSumBatchRequest;
import com.tencent.qf.team.dto.request.SharerOutOrderSumForMiniRequest;
import com.tencent.qf.team.dto.request.SharerOutOrderSumRequest;
import com.tencent.qf.team.dto.response.SharerCommissionDto;
import com.tencent.qf.team.dto.response.SharerOutOrderSumBatchDto;
import com.tencent.qf.team.service.SalesSharerCommissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@Api(value = "收益统计", tags = "收益统计", protocols = "http")
public class SalesSharerCommissionController {


    @Autowired
    private SalesSharerCommissionService salesSharerCommissionService;

    @PostMapping("/api/team/sharer/commission")
    @ApiOperation("查询小b预估佣金-小程序端")
    public HttpResult<SharerCommissionDto> sharerCommission(@RequestBody SharerOutOrderSumForMiniRequest request) {
        log.info("收益统计-查询小b预估佣金-小程序端，入参：{}", JSON.toJSONString(request));
        SharerCommissionDto sharerCommission = salesSharerCommissionService.sharerCommission(request);
        HttpResult<SharerCommissionDto> result = HttpResult.success(sharerCommission);
        log.info("收益统计-查询小b预估佣金-小程序端，出参：{}", JSON.toJSONString(result));
        return result;
    }

    @PostMapping("/api/team/sharerOutOrderSum")
    @ApiOperation("查询小b预估佣金")
    public HttpResult<SharerCommissionDto> sharerOutOrderSum(@RequestBody SharerOutOrderSumRequest request) {
        log.info("查询小b预估佣金，入参：{}", JSON.toJSONString(request));
        SharerCommissionDto sharerCommission = salesSharerCommissionService.sharerOutOrderSum(request);
        HttpResult<SharerCommissionDto> result = HttpResult.success(sharerCommission);
        log.info("查询小b预估佣金，出参：{}", JSON.toJSONString(result));
        return result;
    }

    @PostMapping("/api/team/sharerOutOrderSumBatch")
    @ApiOperation("小B预估收益批量-导购助手")
    public HttpResult<List<SharerOutOrderSumBatchDto>> sharerOutOrderSumBatch(@RequestBody SharerOutOrderSumBatchRequest request) {
        log.info("小B预估收益批量-导购助手，入参：{}", JSON.toJSONString(request));
        List<SharerOutOrderSumBatchDto> sharerOutOrderSumBatch = salesSharerCommissionService.sharerOutOrderSumBatch(request);
        HttpResult<List<SharerOutOrderSumBatchDto>> result = HttpResult.success(sharerOutOrderSumBatch);
        log.info("小B预估收益批量-导购助手，出参：{}", JSON.toJSONString(result));
        return result;
    }
}
